home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 11 / AMUG BBS in a Box Volume XI (April 1994) (MacWizards).iso / Files / Prog / M / LogoMotion101.sit / LogoMation 1.0.1 ƒ / Examples / Lib / Demo ask().lib / Demo ask().lib
Encoding:
Text File  |  1992-10-12  |  3.3 KB  |  111 lines  |  [UVtx/UVtl]

  1. // initDebug and printDebug - debug aids
  2. ////////////////////////
  3. Function initDebug(oldP)
  4.     oldP = penName()
  5.     Pen name="debug"
  6.     Up
  7.     Goto -width()/2 + 10, height()/2 - 10, -90
  8.     Pen fontsize=10
  9.     Pen name=oldP
  10. Function printDebug(s,v,oldP)
  11.     oldP = penName()
  12.     Pen name="debug"
  13.     Print s . " = \"" . v . "\""
  14.     Forward 11
  15.     Pen name=oldP
  16.  
  17. // getName - prompt the user for his/her name
  18. //////////////////////////////////////////
  19. Function getName(n)
  20.     Clear 41230,62275,63487
  21.     Color 65000,44953,5910
  22.     Pen fontsize=14
  23.     Up
  24.     Goto -100,0,0
  25.     Down
  26.     Print "Your name, please: ",move
  27.     Forward 100
  28.     Backward 100
  29.     Pen fontname="Times", fontsize=14
  30.     Color 65535,12866,9734
  31.     n = ask(105)
  32.     If (n = "")        // error if the name is null
  33.         Sound "Boing"
  34.         up
  35.         go x()-120, y()-120, 0
  36.         pr "Run again, please..."
  37.         Halt
  38.     up
  39.     go x()-120, y()-120, 0
  40.     pr "PLEASE WAIT..."
  41.     Return n
  42.  
  43. // makePictures - create a pictures for each letter of the name
  44. /////////////////////////////////////////////////////////
  45. Function makePictures(theName, i, c, r, g, b)
  46.     Repeat i, 0, length(theName)-1, 1
  47.         c = substr(theName, i, 1)
  48.         r = 30000+random(30000)
  49.         g = 30000+random(30000)
  50.         b = 30000+random(30000)
  51.         Picture c
  52.             Color r,g,b
  53.             Pen fontname="Geneva",fontstyle="Bold",fontsize=14
  54.                 Print c
  55.  
  56. // compStartPos - compute the start x,y of each letter
  57. /////////////////////////////////////////////////
  58. Function compStartPos(theName, i)
  59.     Repeat i, 0, length(theName)-1, 1
  60.         startX[i] = random(width()-20) - width()/2
  61.         startY[i] = random(height()-20) - height()/2
  62.  
  63. // compEndPoints - compute the end x of the name's animation
  64. //////////////////////////////////////////////////////////
  65. Function compEndPoints(theName, i)
  66.     Pen fontname="Geneva",fontstyle="Bold",fontsize=14
  67.     Repeat i, 0, length(theName)-1, 1
  68.         endX[i] = sWidth(substr(theName, 0, i))
  69.  
  70. // compPens - compute the pens for the letters' animation
  71. /////////////////////////////////////////////////////
  72. Function compPens(theName, i, dX, c)
  73.     Repeat i, 0, length(theName)-1, 1
  74.         dX = startX[i] - endX[i]
  75.         len[i] = sqrt( dX*dX + startY[i]*startY[i] )
  76.         step[i] = len[i]/20
  77.         c = substr(theName, i, 1)
  78.         Pen name=i, speed=len[i], end="no", picture=c
  79.         Up
  80.         Goto startX[i], startY[i], atan2(startY[i],dX)-180
  81.         Down
  82.  
  83. // MoveThemAll - move all the letters together
  84. ///////////////////////////////////////////
  85. Function MoveThemAll(myName)
  86.     trailMode = "yes"
  87.     Repeat i, 1, 20, 1
  88.         If i > 19
  89.             trailMode="no"
  90.             Pen name=""
  91.             Up
  92.             Goto 0,-sDescent()-1,0
  93.             Down
  94.             Fill 1,65535,65535,65535
  95.                 Repeat 2
  96.                     Forward sWidth(myName)
  97.                     Left 90
  98.                     Forward sDescent()+sAscent()+4
  99.                     Left 90
  100.         //Sound "Pop"
  101.         Repeat c, 0, length(myName)-1, 1
  102.             Pen name=c, trail=trailMode, end="yes"
  103.             Forward step[c]
  104.  
  105. // MoveThemOneByOne - move one by one
  106. /////////////////////////////////////
  107. Function MoveThemOneByOne(myName)
  108.     Repeat c, 0, length(myName)-1, 1
  109.         Pen name=c, trail="yes", end="yes"
  110.         Forward len[c]
  111.